<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>UpGoRemove</title>
<link href="/static/css/bootstrap.css" rel='stylesheet' type='text/css' />
{#<link href="/static/css/style.css" rel='stylesheet' type='text/css' />#}
{#<link rel="stylesheet" href="/static/css/app.css"/>#}
<link href="/static/css/mmenu.css" rel="stylesheet" type="text/css" media="all" />
{#<link rel="stylesheet" href="/static/css/fileinput/fileinput.css"/>#}
<link href="/static/css/baguetteBox/baguetteBox.min.css" rel="stylesheet" type="text/css" />
<link href="/static/css/baguetteBox/thumbnail-gallery.css" rel="stylesheet" type="text/css" />
<link href="/static/css/baguetteBox/htmleaf-demo.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
    <div id="page">
        <div id="header_nav">
            <a href="#menu"></a>
        </div>
        <nav id="menu" style="background-color: #333">
            <ul>
                <li><a href="{{ url_for("main.index") }}">返回首页</a></li>
                <li class="Selected"><a href="#download" class="scroll">图像下载</a></li>
            </ul>
        </nav>
    </div>
    <div class="htmleaf-container">
    		<header class="htmleaf-header">
			<h1>您的图片已就绪，可点击下载 <span>为保护您的图片隐私安全，当您离开本页后，将会立即删除您的所有图片信息。请妥善保存好您需要的图片。</span></h1>
{#			<div>#}
{#				<a class="glyphicon glyphicon-star" href="#" title="yoJo博客" target="_blank">yoJo博客 </a>#}
{#				<a class="glyphicon glyphicon-star" href="#" title="Github" target="_blank">Gtihub </a>#}
{#			</div>#}
{#			<div class="htmleaf-demo center">#}
{#			  <a href="index.html">打包下载</a>#}
{#			</div>#}
		</header>
		<div id="imgHtml" class="container gallery-container">
            <div style="height: 650px">
                <h1>对不起，尚未获取到您的图片信息，请返回 <a href="/" style="color: red">首页</a> 重新生成图片</h1>
            </div>

		</div>
    </div>
</div>


<div class="contact" id="contact">
    <div class="footer">
        <div class="container">
            <p class="copy">REMOVEBACKGROUND FUNCTION MADE BY <a href="https://www.remove.bg">REMOVEBG</a> WEB DEVELOPMENT BY <a href="https://wangxinleo.cn">YOJO</a></p>
        </div>
            <a href="#" id="toTop" style="display: block;"> <span id="toTopHover" style="opacity: 1;"> </span></a>
    </div>
</div>




<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="/static/js/jquery-1.11.1.min.js"></script>
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="/static/js/jquery.mmenu.min.js"></script>
{#<script type="text/javascript" src="/static/js/jquery.easing.min.js"></script>#}
{#<script type="text/javascript" src="/static/js/jquery.mixitup.min.js"></script>#}
<script type="text/javascript" src="/static/js/move-top.js"></script>
<script type="text/javascript" src="/static/js/easing.js"></script>
<script type="text/javascript" src="/static/js/index.js"></script>
<script type="text/javascript" src="/static/js/baguetteBox.min.js"></script>
<script type="text/javascript">
    baguetteBox.run('.tz-gallery');
    showImg();


function showImg(){
    var imgHtml = '<div class="tz-gallery"><div class="row">';
    var temp = window.location.href;
    var tempArry = temp.split('/');
    tempArry = tempArry.slice(-2);
    var url = "/complete/"+tempArry[0];

    $.ajax({
        type:"GET",
        url:url,
        dateType:"json",
        success:function (data) {
           data =  JSON.parse(data);
           if (data.status == 200){
               //if(true) return;
               for(var i=0; i<data.Data.length ; i++){
                   filename = data.Data[i].filename;
                   filepath = data.Data[i].filepath;

                   if(filename.indexOf("zip") !=-1){
                       imgHtml += '<div class="col-sm-6 col-md-4"><div class="thumbnail"><a class="lightbox" href="/static/images/zip.jpg"><img src="/static/images/zip.jpg" alt="Park"></a><div class="caption"><h3>'+filename+'</h3><a id="'+filename+'" onclick="oDownLoad(\''+filename+'\',\''+filepath+'\')" style="color: black;cursor:pointer"><i class="glyphicon glyphicon-save"></i>打包下载</a></div></div></div>';
                   }else{
                       imgHtml += '<div class="col-sm-6 col-md-4"><div class="thumbnail"><a class="lightbox" href="'+filepath+'"><img src="'+filepath+'" alt="Park"></a><div class="caption"><h3>'+filename+'</h3><a id="'+filename+'" onclick="oDownLoad(\''+filename+'\',\''+filepath+'\')" style="color: black;cursor:pointer"><i class="glyphicon glyphicon-save"></i>下载</a></div></div></div>';

                   }
               }
               imgHtml += '</div></div>';
               $('#imgHtml').html(imgHtml);
               baguetteBox.run('.tz-gallery');
           }else{
               {#alert('数据存取错误');#}
           }
        },
        error:function (e) {
        }
    });
}


//判断浏览器类型
function myBrowser() {
	var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
	var isOpera = userAgent.indexOf("Opera") > -1;
	if(isOpera) {
		return "Opera"
	}; //判断是否Opera浏览器
	if(userAgent.indexOf("Firefox") > -1) {
		return "FF";
	} //判断是否Firefox浏览器
	if(userAgent.indexOf("Chrome") > -1) {
		return "Chrome";
	}
	if(userAgent.indexOf("Safari") > -1) {
		return "Safari";
	} //判断是否Safari浏览器
	if(userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
		return "IE";
	}; //判断是否IE浏览器
	if(userAgent.indexOf("Trident") > -1) {
		return "Edge";
	} //判断是否Edge浏览器
}

//IE浏览器图片保存（用window.open)
function SaveAs5(imgURL) {
	var oPop = window.open(imgURL, "", "width=1, height=1, top=5000, left=5000");
	for(; oPop.document.readyState != "complete";) {
		if(oPop.document.readyState == "complete") break;
	}
	oPop.document.execCommand("SaveAs");
	oPop.close();
}

//下载函数（区分IE和非IE部分）

function oDownLoad(name,url) {
	if(myBrowser() === "IE" || myBrowser() === "Edge") {
		//IE （浏览器）
		SaveAs5(url);
		console.log(1)
	} else {
		//!IE (非IE)
        var link = document.getElementById(name);
        $(link).attr("href", url);
        $(link).attr("download", name);
	}

}


window.onbeforeunload = function(){
    var temp = window.location.href;
    var tempArry = temp.split('/');
    tempArry = tempArry.slice(-2);
    var url = "/logout/"+tempArry[0]+"/"+tempArry[1];
    
    $.ajax({
        type: "GET",
        url:url,
        dateType:"text",
        success:function (data) {
            
        },
        error:function (data) {
            
        }
    })

    var msg="为保护您的图片隐私安全，当您离开网页后，将会立即删除您的所有照片信息。再见。ヾ(￣▽￣)Bye~Bye~";
    return msg;
}

</script>
</body>
</html>
